/* Basic data types for LOCKJAW, an implementation of the Soviet Mind Game

Copyright (C) 2006 Damian Yerrick <tepples+lj@spamcop.net>

This work is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

Original game concept and design by Alexey Pajitnov.
The Software is not sponsored or endorsed by Alexey Pajitnov, Elorg,
or The Tetris Company LLC.

*/

package fizzpicks.tetrapulp.tetrapulp;

/**
 * Defines a set of helper methods for dealing with the LJBits object.
 * Created by will
 * Date: May 3, 2008 2:28:21 AM
 */
public class LJBits implements Cloneable {

    public void dirtyNext() {this.dirtyNext = true;}
    public void dirtyScore() {this.dirtyScore = true;}

    public boolean dirtyNext = false;
    public boolean dirtyScore = false;
    public int bits = 0;

    public LJBits clone(){
        try {
            return (LJBits)super.clone();
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
            return null;
        }
    }
    public LJBits() {
    }
    public LJBits(boolean fill) {
        if(fill) this.bits = ~0;
    }
    public LJBits fill() {
        this.bits = ~0;
        return this;
    }
    public LJBits(int set) {
        bits = set;
    }
    public LJBits add(int b) {
        this.bits |= b;
        return this;
    }
    public LJBits add(LJBits b) {
        this.bits |= b.bits;
        return this;
    }
    public LJBits addBit(int i) {
        this.bits |= 1 << i;
        return this;
    }
    public LJBits clear() {
        this.bits = 0;
        return this;
    }
    public boolean get(int i) {
        return ((bits & (1 << i)) != 0);
    }
    public LJBits set(int i) {
        this.bits |= 1 << i;
        return this;
    }
    public boolean isEmpty() {
        return bits == 0;
    }
}
